//
//  AppDelegate.m
//  MeToo
//
//  Created by 俊松何 on 2018/7/3.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import "AppDelegate.h"
#import "MTMainViewController.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import "MTLoginFristController.h"
#import "MTCompationInfoController.h"
#import "MTValidationCodeController.h"
#import <PLRTCStreamingKit/PLRTCStreamingKit.h>
#import "LTThridKeyCfgManger.h"
#import "MTFristViewController.h"
//#import "MJAduioVideoViewController.h"
#import <JPush/JPUSHService.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [InternationalControl initInternationalLanguage];
//    [[LTThridKeyCfgManger manager] InitializeAllSDK];
    
    [[FanqieApiHelper helper] initializeFanqie];

    _window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];

    _window.rootViewController = [[MTFristViewController alloc] init];
    [_window makeKeyAndVisible];
    return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    
     [[LTClient sharedClient] enterBackgroundClick];
    
}

- (void)applicationWillEnterForeground:(UIApplication *)application {

    [[NSNotificationCenter defaultCenter] postNotificationName:@"applicationWillEnterForeground" object:nil];
     [[LTClient sharedClient] becomeActiveClick];
    
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    
}


- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    if (application.applicationState==UIApplicationStateActive) {
        return;
    }
    NSString *url =  userInfo[@"url"];
    if ([url rangeOfString:@"MT://UI/CHAT/CHATLIST"].location!=NSNotFound)
    {
        UITabBarController *tabVc =(UITabBarController *)kWindow.rootViewController;
        if([tabVc isKindOfClass:[MTMainViewController class]])
        {
            tabVc.selectedIndex = 2;
        }
    }
}




- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [JPUSHService handleRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    /// Required - 注册 DeviceToken
    [JPUSHService registerDeviceToken:deviceToken];
}




- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
